#include "suite.h"

Suite::Suite(DataSuite *parent) :
    DataSuite(parent)
{
}

QVariant Suite::value(int field, int role) const
{
    if (field < 0)
    {
        return QVariant();
    }

    if (role != Qt::DisplayRole && role != Qt::EditRole)
    {
        return QVariant();
    }

    if (field < metaObject()->propertyCount())
    {
        return DataSuite::value(field, role);
    }

    return fieldName(field);
}

bool Suite::setValue(int field, const QVariant &value, int role)
{
    if (role != Qt::EditRole || field < 0)
    {
        return false;
    }


    if (field < metaObject()->propertyCount())
    {
        return DataSuite::setValue(field, value, role);
    }

    MetaData* meta = metaData();
    if (!meta)
    {
        return false;
    }

    meta->setItemName(field, value.toString());
    return true;
}
